package ru.tulupov.collectionsbenchmark;

public class Statistic {
	private String description;
	private double time;

	public void update(String description, double time) {
		if (description == null) {
			throw new IllegalArgumentException();
		}

		if (this.description == null) {
			this.description = description;
			this.time = time;
		} else {
			if (this.time > time) {
				this.description = description;
				this.time = time;
			}
		}
	}

	@Override
	public String toString() {
		String s = null;
		if (description == null) {
			s = "Statistics are unavailable";
		} else {
			s = String.format("%s [%.09f]", description, time);
		}
		return s;
	}
}
